#pragma once
#include "../Essentials/Vertex.h"
#include "../scion_utilities/hzpch.h"

namespace SCION_RENDERING
{

  class BatchRenderer
  {
  private:
    struct Batch
    {
      GLuint nuIndices{0}, offset{0}, textureID{0};
    };
    struct Sprite
    {
      Vertex topLeft, topRight, bottomLeft, bottomRight;
      int Layer;
      GLuint textureID;
    };

  private:
    GLuint m_VAO, m_VBO, m_IBO;
    std::vector<std::shared_ptr<Sprite>> m_Sprites;
    std::vector<std::shared_ptr<Batch>> m_Batches;

  private:
    void Initialize();
    void GenerateBatches();

  public:
    BatchRenderer();
    ~BatchRenderer();

    void Begin();
    void End();
    void Render();

    void AddSprite(const glm::vec4 &spriteRect, const glm::vec4 uvRect, GLuint textureID, int layer = 0, glm::mat4 model = glm::mat4(1.0f), const Color &color = Color{255, 255, 255, 255});
  };
}